package cn.iocoder.yudao.module.product.controller.app.spu.vo;

import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
public class AppProductSkuRespPropertyValueVO {
    @Schema(description = "ID")
    private Long id;
    @Schema(description = "名称")
    private String name;
    @Schema(description = "营销标签")
    private String tag;
    @Schema(description = "排序")
    private Integer sort;
    @Schema(description = "是否为默认值")
    private boolean isDefault;

    public static AppProductSkuRespPropertyValueVO fromProductPropertyValue(ProductPropertyValueDO propertyValue) {
        AppProductSkuRespPropertyValueVO vo = new AppProductSkuRespPropertyValueVO();
        vo.id = propertyValue.getId();
        vo.name = propertyValue.getName();
        vo.tag = propertyValue.getPromotionMark();
        vo.sort = propertyValue.getSort();
        vo.isDefault = propertyValue.getIsDefault() != null && propertyValue.getIsDefault().equals(1);
        return vo;
    }
}
